<extend name="Layout:layout_dialog" />
<block name="body_main">
    <form action="{:U('product_specification_goods_edit_save')}" method="post" class="xsui-form" enctype="multipart/form-data" style="min-width:800px;">
        <fieldset>
            <div class="xsui-form-field">
                <label>商品名称：</label>
                <input type="text" name="title" placeholder="商品名称" value="{$data.title}" title="{$data.title}" size="80" required="required" />
            </div>
            <div class="xsui-form-field">
                <label>商品型号：</label>
                <input type="text" name="marque" placeholder="商品型号" value="{$data.marque}" title="商品型号" required="required" />
            </div>
            <div class="xsui-form-field">
                <label>商品价格：</label>
                <input type="text" name="price" value="{$data.price|default=0}"  placeholder="商品价格" required="required" />
            </div>
            <div class="xsui-form-field">
                <label>价格提示：</label>
                <input type="text" name="price_alt" value="{$data.price_alt|default='面议'}"  placeholder="价格提示" required="required" />
            </div>
            <div class="xsui-form-field">
                <label>隐藏价格：</label>
                <input type="checkbox" name="price_status" value="Y" title="是否显示销售价格" />
            </div>
            <div class="xsui-form-field">
                <label>商品图片：</label>
                <sohtml:file name="picture_url" value="{$data.picture_url}" />
                <input type="hidden" name="picture_url2" value="{$data.picture_url}" />
            </div>
            <div class="xsui-form-field">
                <label>规格设置：</label>
                <table id="specification-picker" class="xsui-table-bordered" data-value="{$data.specification_code}">
                    <tr>
                    <foreach name="list" item="vo">
                        <if condition="($key gt 0) and ($key % 2 eq 0)">
                        </tr><tr>
                </if>
                <th>{$vo.title}</th>
                <td>
                    <select name="specification[]">
                        <foreach name="vo['children']" item="vo2">
                            <option value="{$vo2.id}">{$vo2.title}</option>
                        </foreach>
                    </select>
                </td>
            </foreach>
            <if condition="is_array($list) and (count($list) % 2 gt 0)">
                <td colspan="2">&nbsp;</td>
            </if>
            </tr>
        </table>
    </div>
    <div class="xsui-form-field xsui-form-mgb">
        <label>状态：</label>
        <sohtml:radio name="status" items="1:上架;0:下架" value="{$data.status|default='1'}" required="required" />
    </div>
</fieldset>
<button type="submit" class="ui-state-default"><i class="fa fa-save"></i>发布</button>
<button type="reset" class="ui-state-default">重置</button>
<input type="hidden" name="id" value="{$data.id}"/>
<input type="hidden" name="pid" value="{$data.pid}"/>
<input type="hidden" name="category_id" value="{$data.category_id}"/>
<input type="hidden" name="site_id" value="{$data.site_id}"/>
<input type="hidden" name="user_name" value="{$data.user_name}"/>
</form>
</block>
<block name="body_after">
    <script type="text/javascript">
        // 自动勾选规格 2016-8-25 SoChishun Added.
        if ($('#specification-picker').data('value')) {
            var $spectable = $('#specification-picker');
            var avalue = $spectable.data('value').split('.');
            for (var i in avalue) {
                if (!i) {
                    continue;
                }
                $('select[name="specification[]"] option[value="' + avalue[i] + '"]').prop('selected', true);
            }
        }
    </script>
</block>